package com.huang.tiger.utils;

import java.util.ArrayList;
import java.util.List;

public class IDUtils {

    private static final String [] CAPITAL = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    private static final String [] LOWERCASE = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

    public static String randomID(){
        String nowTimeStr = System.currentTimeMillis()+"";
        char[] nowTimeArr = nowTimeStr.toCharArray();
        String id = "";
        for(Character nowTimeChar:nowTimeArr){
            Integer nowTimeInt = Integer.parseInt(nowTimeChar + "");
            Integer randomInt = RandomUtils.randomInt(17);
            id += CAPITAL[nowTimeInt+randomInt]+nowTimeChar+LOWERCASE[nowTimeInt+randomInt];
        }
        id = RandomUtils.disrupt(id);
        String one = nowTimeStr.substring(1,3);
        String two = nowTimeStr.substring(4,6);
        String three = nowTimeStr.substring(7,9);
        String four = nowTimeStr.substring(9,12);
        char[] idArr = id.toCharArray();
        List<String> idList = new ArrayList<>();
        for(Character idChar:idArr){
            idList.add(idChar+"");
        }
        idList.add(8,one);
        idList.add(16,two);
        idList.add(24,three);
        idList.add(32,four);
        id = "";
        for(String iditem:idList){
            id += iditem;
        }
        return id;
    }
}
